home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / queue.zip / QUEUE / QUEUE.H < prev    next >
C/C++ Source or Header  |  1992-10-11  |  5KB  |  147 lines

  1. /************************************************************************\
  2. * The enclosed files, "the software," is provided by 
  3. * Microsoft Corporation "as is" without warranty of any kind. 
  4. * MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, 
  5. * INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY 
  6. * AND FITNESS FOR A PARTICULAR PURPOSE.  You assume all risks of 
  7. * using the software.
  8. * The software is Copyright (c) 1992 Microsoft Corporation.
  9. * Original Author: John M. Hall, Microsoft SDE  9/1/92
  10. *
  11. * You are granted the right to freely distribute this software.
  12. * You are granted the right to make changes provided this comment block
  13. * is retained without modification and you acknowledge the changes.
  14. \************************************************************************/
  15. /************************************************************************\
  16. *
  17. *                               QUEUE.H
  18. *
  19. \************************************************************************/
  20.  
  21. #ifndef QUEUE_DLL_H
  22. #define QUEUE_DLL_H
  23.  
  24. /************************************************************************\
  25. *                         SYMBOLIC CONSTANTS
  26. \************************************************************************/
  27.  
  28. #define QUE_INVALID_NAME      1000
  29. #define QUE_NO_MEMORY         1001
  30. #define QUE_NAME_NOT_EXIST    1002
  31. #define QUE_ELEMENT_NOT_EXIST 1003
  32. #define QUE_INVALID_HANDLE    1004
  33. #define QUE_EMPTY             1005
  34.  
  35. #define QUE_FIFO           1
  36. #define QUE_LIFO           2
  37. #define QUE_PRIORITY       3
  38.  
  39. #ifdef QUEUE_DLL_C
  40. #define INFINITE    0xFFFFFFFF
  41. #define MUNGE       37
  42. #define MAGIC       0x4a6d4800
  43. #define MAX_QUEUES  32
  44. #define QUEUE_LIMIT 100
  45.  
  46.  
  47. /************************************************************************\
  48. *                          GLOBAL SHARED VARIABLES
  49. \************************************************************************/
  50.  
  51. DWORD dwProcesses;
  52. int   iQueues;
  53.  
  54. /************************************************************************\
  55. *                          GLOBAL NON-Shared VARIABLES
  56. \************************************************************************/
  57.  
  58. HANDLE hMod       = NULL;
  59. HANDLE hGlobalSem = NULL;
  60. HANDLE hControl = NULL;
  61. LPVOID lpCtrlBase = NULL;
  62. DWORD  dwProcessID = 0;
  63. FILE *fp_log = NULL;
  64. LPBYTE lpBase = NULL;
  65.  
  66. /************************************************************************\
  67. *                          MACROS
  68. \************************************************************************/
  69. #define MAKE_PTR(a,b)  ((LPVOID)((DWORD)(a) + (b)))
  70. #define MUNGEIT(a) ( ((a)+1)* MUNGE)
  71. #define UNMUNGE(a) ( ((a)/MUNGE)-1)
  72.  
  73. #ifdef DEBUG
  74. #define AssertBox(a,b) if (!(a)) MyAssertBox((b), #a, __FILE__, __LINE__)
  75. #else
  76. #define AssertBox(a,b)
  77. #endif
  78.  
  79. #endif // QUEUE_DLL_C
  80. /************************************************************************\
  81. *                          STRUCTURES
  82. \************************************************************************/
  83.  
  84. typedef struct _queue_elem {
  85.     DWORD  dwWriterId;
  86.     DWORD  dwShrHandle;
  87.     DWORD  dwEventCode;
  88.     DWORD  dwPriority;
  89.  
  90. } Q_ELEMENT;
  91. typedef Q_ELEMENT *PQ_ELEMENT;
  92.  
  93. #ifdef QUEUE_DLL_C
  94. typedef struct {
  95.     DWORD  dwMagic;
  96.     DWORD  dwProcId;
  97.     HANDLE hEvent;
  98.     HANDLE hSem;
  99.     int    iIndex;
  100. } QUEUE;
  101. typedef QUEUE *HQUEUE;
  102. typedef HQUEUE *PHQUEUE;
  103.  
  104. typedef struct _queue_data {
  105.     DWORD  dwCreator;
  106.     WORD   wType;
  107.     ATOM   aQueueName;
  108.     short  sElements;  
  109.     Q_ELEMENT  elem[QUEUE_LIMIT];
  110. } QUEUE_DATA;
  111. typedef QUEUE_DATA *PQUEUE_DATA;
  112.  
  113. #else
  114.  
  115. typedef DWORD  HQUEUE;
  116. typedef HQUEUE *PHQUEUE;
  117.  
  118. #endif
  119.  
  120. /************************************************************************\
  121. *                         FLAGS
  122. \************************************************************************/
  123.  
  124. /************************************************************************\
  125. *                         FUNCTION PROTOTYPES
  126. \************************************************************************/
  127. VOID    MyAssertBox( const char *, const char *, const char *, int);
  128.  
  129. BOOL    QueueEntry (HANDLE hDLL, DWORD dwReason, LPVOID lpReserved);
  130. BOOL attach_ctl();
  131. BOOL IsValidHqueue( HQUEUE hqueue);
  132. DWORD CreateQueue( PHQUEUE phq, int fQueueOrder, LPTSTR pszName);
  133. DWORD CloseQueue( HQUEUE hq);
  134. DWORD OpenQueue(LPDWORD ppid, PHQUEUE phq, LPTSTR pszName);
  135. void push_down( int iIndex, int jj);
  136. void push_up( int iIndex, int jj);
  137. DWORD WriteQueue(HQUEUE hq, DWORD dwEventCode, DWORD dwShrHandle, DWORD dwPriority);
  138. DWORD ReadQueue(HQUEUE hq, PQ_ELEMENT pqe, int iElement, BOOL fWait);
  139. HANDLE GetQueueEventHandle( HQUEUE hqueue);
  140. DWORD  ShrFree(DWORD);
  141. DWORD PeekQueue(HQUEUE hq, PQ_ELEMENT pqe, int *piElement, BOOL fWait);
  142.  
  143.  
  144. #endif // QUEUE_DLL_H
  145.